#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import sys
import time

# 设置标准输出编码为UTF-8（Windows兼容性）
if sys.platform == "win32":
    import io
    sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8')
    sys.stderr = io.TextIOWrapper(sys.stderr.buffer, encoding='utf-8')

def main():
    print("🎉 欢迎使用交互式脚本系统！")
    print("=" * 50)
    
    step = 1
    name = ""
    age = 0
    selected_hobby = ""
    
    while True:
        if step == 1:
            # 获取用户姓名
            print("请输入您的姓名: ")
            try:
                name = input().strip()
                if name:
                    print(f"你好, {name}! 很高兴认识你！")
                    step = 2                   
                else:
                    print("姓名不能为空，请重新输入！")
            except KeyboardInterrupt:
                print("\n\n程序被用户中断")
                break

                
        elif step == 2:
            # 获取用户年龄
            print("请输入您的年龄: ")
            try:
                age = int(input())
                if age < 0:
                    print("年龄不能为负数，请重新输入！")
                    continue
                elif age > 150:
                    print("这个年龄似乎不太现实，请重新输入！")
                    continue
                else:
                    print(f"原来您今年 {age} 岁！")
                    
                    # 根据年龄给出不同的回应
                    if age < 18:
                        print("你还很年轻，要好好学习哦！ 📚")
                    elif age < 30:
                        print("正值青春年华，要好好奋斗！ 💪")
                    elif age < 60:
                        print("人生阅历丰富，继续加油！ 🌟")
                    else:
                        print("人生智慧深厚，令人敬佩！ 🙏")
                    
                    step = 3
            except ValueError:
                print("请输入一个有效的数字！")
                
        elif step == 3:
            # 选择兴趣爱好
            print("\n请选择你的兴趣爱好（输入数字）:")
            hobbies = ["编程", "阅读", "运动", "音乐", "旅行", "摄影"]
            for i, hobby in enumerate(hobbies, 1):
                print(f"{i}. {hobby}")
            
            print("请输入选择 (1-6): ", end="", flush=True)
            try:
                choice = int(input())
                if 1 <= choice <= 6:
                    selected_hobby = hobbies[choice - 1]
                    print(f"太棒了！{selected_hobby} 是一个很好的爱好！")
                    step = 4
                else:
                    print("请输入 1-6 之间的数字！")
            except ValueError:
                print("请输入一个有效的数字！")
                
        elif step == 4:
            # 最终总结
            print("\n" + "=" * 50)
            print("个人信息总结:")
            print(f"姓名: {name}")
            print(f"年龄: {age} 岁")
            print(f"兴趣: {selected_hobby}")
            print("=" * 50)
            
            # 倒计时结束
            print("\n程序将在 3 秒后结束...")
            for i in range(3, 0, -1):
                print(f"{i}...")
            
            print("再见！感谢使用我们的系统！ 👋")
            break

if __name__ == "__main__":
    main()
